<template>
  <div class="r-item">
    <div class="r-item__title">
      {{ props.title }}
      <m-digital :number="rate" uom="%" :color="digitalColor" />
    </div>
    <div class="r-item__content">
      <dv-active-ring-chart :config="config" />
    </div>
  </div>
</template>

<script setup>
const props = defineProps({
  title: {
    type: String,
    default: ''
  },
  rate: {
    type: Number,
    default: 0
  },
  data: {
    type: Array,
    default: () => {
      return []
    }
  },
  digitalColor: {
    type: String,
    default: '#7FFF00'
  },
  colors: {
    type: Array,
    default: () => {
      return []
    } // ['#FFDB5C', '#37A2DA', '#9FE6B8']
  },
  loading: {
    type: Boolean,
    default: false
  }
})
const config = computed(() => {
  return {
    radius: '40%',
    activeRadius: '45%',
    data: props.data,
    digitalFlopStyle: {
      fontSize: 18
    },
    showOriginValue: true,
    lineWidth: 20,
    color: props.colors
  }
})
</script>
<style lang="less" scoped>
.r-item {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  .r-item__title {
    text-align: center;
    margin-bottom: 5px;
    font-size: 14px;
    line-height: 20px;
    .m-digital {
      display: inline-block;
      font-size: 16px;
      padding: 0;
    }
  }
  .r-item__content {
    // width: 110px;
    // height: 110px;
    width: 96%;
    height: calc(100% - 25px);
    overflow: hidden;
    position: relative;
    .dv-active-ring-chart {
      width: 300px;
      height: 300px;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%) scale(0.7);
    }
  }
}
</style>
